package com.headwind.logistics.system.controller;

import com.headwind.logistics.common.pojo.Message;
import com.headwind.logistics.common.util.LayuiUtil;
import com.headwind.logistics.log.annotate.Log;
import com.headwind.logistics.system.service.intl.MessageServiceIntl;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 桂祥宇
 * @Date 2020/7/24 0024 9:20
 * @Version 1.0
 * @DESCRIPTION 消息通知控制器层
 */
@Controller
public class MessageController {
    //消息通知业务逻辑层接口
    @Resource
    private MessageServiceIntl messageServiceIntl;

    @GetMapping("/admin/system/queryAllMessage")
    @ResponseBody
    @Log("查询所有消息通知")
    public LayuiUtil queryAllMessage(Integer page, Integer limit){

        List<Message> messages=messageServiceIntl.queryAllMessage(page, limit);

        return LayuiUtil.data(messageServiceIntl.queryAllMessage(null,null).size(),messages);
    }

    @GetMapping("/admin/system/deleteMessage")
    @ResponseBody
    @Log("根据id删除消息通知")
    public int deleteMessage(int messgaeId){
        int count =messageServiceIntl.deleteMessage(messgaeId);
        return count;
    }

    @GetMapping("/admin/system/addMessage")
    @ResponseBody
    @Log("新增消息通知")
    public int addMessage(Message message){
        int count =messageServiceIntl.addMessage(message);
        return count;
    }

    @GetMapping("/admin/system/updateMessage")
    @ResponseBody
    @Log("修改消息通知")
    public int updateMessage(Message message){

        int count =messageServiceIntl.updateMessage(message);
        return count;
    }


    @GetMapping("/admin/system/updateMessageCancelTime")
    @ResponseBody
    @Log("修改消息通知撤销时间")
    public int updateMessageCancelTime(Message message){
        System.out.println(message.getMessgaeCancelTime());
        int count =messageServiceIntl.updateMessageCancelTime(message);
        return count;
    }
}
